﻿@page "/tables/excel"
@inject IStringLocalizer<TablesExcel> Localizer

<h3>@Localizer["TablesExcelTitle"]</h3>
<h4>@Localizer["TablesExcelDescription"]</h4>

<DemoBlock Title="@Localizer["TablesExcelOnQueryTitle"]"
           Introduction="@Localizer["TablesExcelOnQueryIntro"]"
           Name="OnQuery"
           Demo="typeof(Demos.Table.TablesExcel.TablesExcelOnQuery)">
</DemoBlock>

<p class="mt-3">@((MarkupString)Localizer["TablesExcelTips"].Value)</p>

<p>
    <div class="code-label">@((MarkupString)Localizer["TablesExcelSetDataSourceTitle"].Value)</div>
    <div class="mt-2">@((MarkupString)Localizer["TablesExcelSetDataSourceDescription"].Value)</div>
</p>

<Pre>protected override void OnInitialized()
{
    base.OnInitialized();

    Items = Foo.GenerateFoo(Localizer);
}</Pre>

<p>
    <div class="code-label">@((MarkupString)Localizer["TablesExcelNewLogicTitle"].Value)</div>
    <div class="mt-2">@((MarkupString)Localizer["TablesExcelNewLogicDescription"].Value)</div>
</p>

<Pre>private Task&lt;Foo&gt; OnAddAsync()
{
    // @Localizer["TablesExcelNewLogicNote1"]
    var foo = new Foo() { DateTime = DateTime.Now, Address = $"@Localizer["TablesExcelNewLogicNote1Address"] {DateTime.Now.Second}" };
    Items.Insert(0, foo);

    // @Localizer["TablesExcelNewLogicNote2"]
    Trace.Log($"@Localizer["TablesExcelNewLogicNote2Log1"]: {Items.Count} - @Localizer["TablesExcelNewLogicNote2Log2"]: Add");
    return Task.FromResult(foo);
}</Pre>

<p>
    <div class="code-label">@((MarkupString)Localizer["TablesExcelDeleteLogicTitle"].Value)</div>
    <div class="mt-2">@((MarkupString)Localizer["TablesExcelDeleteLogicDescription"].Value)</div>
</p>

<Pre>private Task&lt;bool&gt; OnDeleteAsync(IEnumerable&lt;Foo&gt; items)
{
    // @Localizer["TablesExcelDeleteLogicNote1"]
    Items.RemoveAll(i => items.Contains(i));

    // @Localizer["TablesExcelDeleteLogicNote2"]
    Trace.Log($"@Localizer["TablesExcelDeleteLogicNote2Log1"]: {Items.Count} - @Localizer["TablesExcelDeleteLogicNote2Log2"]: Delete");
    return Task.FromResult(true);
}</Pre>

<p>
    <div class="code-label">@((MarkupString)Localizer["TablesExcelUpdateLogicTitle"].Value)</div>
    <div class="mt-2">@((MarkupString)Localizer["TablesExcelUpdateLogicDescription1"].Value)</div>
    <div class="mt-2">@((MarkupString)Localizer["TablesExcelUpdateLogicDescription2"].Value)</div>
</p>

<Pre>private Task&lt;bool&gt; OnDeleteAsync(Foo item, ItemChangedType changedType)
{
    // @Localizer["TablesExcelUpdateLogicNote"]
    Trace.Log($"@Localizer["TablesExcelUpdateLogicLog1"] - @Localizer["TablesExcelUpdateLogicLog2"]");
    return Task.FromResult(true);
}</Pre>

<DemoBlock Title="@Localizer["TablesExcelCellRenderTitle"]"
           Introduction="@Localizer["TablesExcelCellRenderIntro"]"
           Name="CellRender"
           Demo="typeof(Demos.Table.TablesExcel.TablesExcelCellRender)">
    <ul class="ul-demo mb-3">
        <li>@((MarkupString)Localizer["TablesExcelCellRenderTips1"].Value)</li>
        <li>@((MarkupString)Localizer["TablesExcelCellRenderTips2"].Value)</li>
    </ul>
</DemoBlock>
